package de.trebings.gia.util;

import java.util.List;

import de.trebings.gia.entities.IdeaLike;

public class IdeaLikeList {
	List<IdeaLike> likeList;

	public IdeaLikeList(List<IdeaLike> list) {
		this.likeList = list;
	}

	public String getLikeString(UserManager um) {
		String response = "";

		if (likeList.size() > 0) {
			boolean firstUser = true;
			for (IdeaLike like : likeList) {
				String userName;
				if (like.getUserId() == um.getAuthorizedUser().getId()) {
					userName = "Dich";
				} else {
					userName = um.getUserById(like.getUserId()).getFirstName();
				}
				if (firstUser) {
					response += userName;
					firstUser = false;
				} else {
					response += ", " + userName;
				}
//				response += "(" + like.getUserId() + ")";
			}
			response += " begeistert das";
		} else {
			response = "begeistert bislang noch keinen";
		}
//		response += " (authUserId:" + um.getAuthorizedUser().getId() + ")";
		return response;
	}

	public String getAlreadyLiked(UserManager um) {
		for(IdeaLike like : likeList){
			if(like.getUserId() == um.getAuthorizedUser().getId()){
				return "X";
			}
		}
		
		return " ";
	}
}
